<?php

/**
 * 作者：lucas
 * 链接：
 * 邮箱：dissipator_520@qq.com
 */

/**
 * 客户模型
 *
 * @author lucas
 */

class CustomViewModel extends ViewModel {

    public $_validate = array(
        array('c_id', 'require', '名称必须'),
        array('需求品种', 'require', '需求品种必须'),
        array('需求数量', 'require', '需求数量必须')
    );

    protected $viewFields = array(
        'khask' => array('ID', 'PO','邮件时间', '需求品种','需求数量','开始时间','截止时间','实际发货数量','status','备注','c_id'),
        'khinf' => array('saname','name', '_on' => 'khask.c_id=khinf.id')
    );

    function getCustominfData($id) {

        $Model = M("khinf");
        // return 3;
        if($id){
            // return 1;
        $data = $Model->where(array('ID' => $id))->page($this->page, $this->rows)->select();
        $counts= $Model->where(array('ID' => $id))->count();
        }
        else{
            // return 2;
            $data = $Model->page($this->page, $this->rows)->select();
            $counts= $Model->count();
        }
        return array($data,$counts);
    }

}